import { Language } from "../../../../../extend/language/Language";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { RadioButtonGroup } from "../../../../../fl/controls/RadioButtonGroup";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { AcupointData } from "./AcupointData";
import { GRadioButton } from "../../../../../com/mui/controls/GRadioButton";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { AcupointConfig } from "../../../resource/AcupointConfig";
import { SAcupointInfo } from "../../../../../Message/Game/SAcupointInfo";
type int = number;
//class AcupointSelecter
    
    export  class AcupointSelecter /* flash.display.Sprite */
    {
        constructor(arg1: int=1)
        {
            this._dataArr = [{"name": Language.getString(30116), "step": 1}, {"name": Language.getString(30117), "step": 2}, {"name": Language.getString(30118), "step": 3}, {"name": Language.getString(30119), "step": 4}, {"name": Language.getString(30120), "step": 5}, {"name": Language.getString(30121), "step": 6}, {"name": Language.getString(30122), "step": 7}, {"name": Language.getString(30123), "step": 8}];
            this._btnDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._textArr = [];
            
            this._type = arg1;
            this.init(arg1);
            return;
        }

        /* internal  */init(arg1: int): void
        {
            var loc3=null;
            var loc6=null;
            var loc7=null;
            var loc1=ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            loc1.width = 110;
            loc1.height = 395;
            addChild(loc1);
            var loc2=new RadioButtonGroup("rbg");
            var loc4=10;
            var loc5=5;
            var loc8=0;
            while (loc8 < 8) 
            {
                (loc3 = ObjCreate.createRadioButton(this._dataArr[loc8].name, loc4, loc5, 80, 30, this, "GRadioButtonBig")).addEventListener(flash.events.MouseEvent.CLICK, this.onRadioBtnClickHandler);
                loc3.value = this._dataArr[loc8].step;
                loc3.group = loc2;
                loc5 = loc5 + 47;
                this._btnDic[this._dataArr[loc8].step] = loc3;
                if (loc8 < 7) 
                {
                    loc6 = ObjCreate.createBg(5, loc5, 100, 2, this, ImagesConst.SplitLine);
                }
                if (arg1 != 1) 
                {
                    loc7 = ObjCreate.createTextField("", 10, loc3.y + 25, 100, 20, this, new GTextFormat("", 12, 16776960));
                    this._textArr.push(loc7);
                }
                ++loc8;
            }
            this._levelTxt = ObjCreate.createTextField("", 55, 10, 60, 20, this, new GTextFormat("", 12, 65280));
            this._levelTxt.filters = [];
            this._effectTxt = ObjCreate.createTextField("", 10, 30, 100, 20, this, new GTextFormat("", 12, 16776960));
            this._effectTxt.filters = [];
            this._acupointInfo = AcupointData.acupointInfo;
            return;
        }

        /* internal  */onRadioBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as GRadioButton;
            dispatchEvent(new DataEvent(EventName.AcupointSelecterChange, loc1.value));
            this._levelTxt.y = loc1.y + 5;
            if (this._type == 1) 
            {
                this._effectTxt.y = loc1.y + 25;
            }
            this.updateAcupointInfo(loc1.value as int);
            return;
        }

        public setCurrentRadioBtn(arg1: int): void
        {
            var loc1=this._btnDic[arg1] as GRadioButton;
            loc1.selected = true;
            dispatchEvent(new DataEvent(EventName.AcupointSelecterChange, arg1));
            this._levelTxt.y = loc1.y + 5;
            if (this._type == 1) 
            {
                this._effectTxt.y = loc1.y + 25;
            }
            this.updateAcupointInfo(arg1);
            return;
        }

        /* internal  */updateAcupointInfo(arg1: int): void
        {
            var loc5=0;
            var loc6=null;
            var loc1=Cache.instance.role.careerBasic;
            var loc2=Cache.instance.role.careerEnabled;
            var loc3=AcupointData.getAttributesByStep(arg1, 1, this._acupointInfo.attributes);
            var loc4=AcupointData.getAttributeStr(loc3, "", loc1, loc2, true, false);
            if (this._type == 4) 
            {
                loc6 = AcupointData.getAttributeStr(loc3, "", loc1, loc2, false, false);
                this._levelTxt.text = loc6;
            }
            else 
            {
                loc5 = AcupointData.getAcupointCurLevel(arg1, this._acupointInfo);
                this._levelTxt.text = "LV." + loc5;
            }
            if (this._type != 1) 
            {
                if (this._type != 3) 
                {
                    if (this._type == 4) 
                    {
                        this.updateRootText();
                    }
                }
                else 
                {
                    this.updateSavvyText();
                }
            }
            else 
            {
                this._effectTxt.text = loc4;
            }
            return;
        }

        public updateAcupointText(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=0;
            while (loc4 < this._textArr.length) 
            {
                loc1 = AcupointData.getRootLevel(loc4 + 1);
                loc2 = AcupointData.getRootBreakThroughsLevelByStep(loc4 + 1);
                loc3 = this._textArr[loc4] as Object /* flash.text.TextField */;
                if (AcupointConfig.instance.isCanBreakThrough(loc1) && loc1 == loc2) 
                {
                    loc3.text = Language.getString(30230);
                }
                else 
                {
                    loc3.text = "";
                }
                ++loc4;
            }
            return;
        }

        public updateSavvyText(): void
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            while (loc4 < this._textArr.length) 
            {
                loc2 = this._textArr[loc4] as Object /* flash.text.TextField */;
                loc1 = AcupointData.getSavvyLevel(loc4 + 1);
                loc3 = this._btnDic[loc4 + 1] as GRadioButton;
                if (loc1 >= 100) 
                {
                    loc2.text = Language.getString(30251);
                }
                else if (loc3.selected) 
                {
                    if (loc3.selected) 
                    {
                        loc2.text = Language.getString(30252) + loc1;
                    }
                }
                else 
                {
                    loc2.text = "";
                }
                ++loc4;
            }
            return;
        }

        public updateRootText(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            while (loc6 < this._textArr.length) 
            {
                loc3 = this._textArr[loc6] as Object /* flash.text.TextField */;
                loc1 = AcupointData.getRootLevel(loc6 + 1);
                loc2 = AcupointData.getRootBreakThroughsLevelByStep(loc6 + 1);
                loc5 = AcupointData.getRootBreakThroughsLevelByStep(loc6 + 1);
                loc4 = this._btnDic[loc6 + 1] as GRadioButton;
                if (AcupointConfig.instance.isCanBreakThrough(loc1) && loc1 == loc5) 
                {
                    loc3.text = Language.getString(30230);
                }
                else if (loc4.selected) 
                {
                    if (loc4.selected) 
                    {
                        loc3.text = Language.getString(30135) + loc1 + " / " + loc2;
                    }
                }
                else 
                {
                    loc3.text = "";
                }
                ++loc6;
            }
            return;
        }

        /* internal */ /* var */_dataArr: Array<any>;

        /* internal */ /* var */_btnDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_acupointInfo: SAcupointInfo;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_effectTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_type: int=1;

        /* internal */ /* var */_textArr: Array<any>;
    }
